<template>
    <div class="withdraw-unhadle">
        <el-form :inline="true" :model="formInline">
            <el-form-item label="城市">
                <el-input v-model="formInline.city" placeholder="城市"></el-input>
            </el-form-item>
            <el-form-item label="昵称">
                <el-input v-model="formInline.nickname" placeholder="昵称"></el-input>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" @click="search">搜索</el-button>
                <el-button type="primary" @click="reset">重置</el-button>
            </el-form-item>
        </el-form>
        <el-table
            :header-cell-style="{color:'#555555'}"
            class="black"
            :data="tableData"
            stripe
            border
            style="width: 100%">
            <el-table-column
                prop="account"
                label="账号"
                align="center">
            </el-table-column>
            <el-table-column
                prop="sex"
                label="性别"
                align="center">
                <template slot-scope="scope">
                {{scope.row.sex == 0?'男':'女'}}
                </template>
            </el-table-column>
            <el-table-column
                prop="city"
                label="所在城市"
                align="center">
            </el-table-column>
            <el-table-column
                prop="nickname"
                label="昵称"
                align="center">
            </el-table-column>
            <el-table-column
                prop="identity"
                label="认证"
                align="center">
                <template slot-scope="scope">
                {{scope.row.identity == 0?'未认证':'已认证'}}
                </template>
            </el-table-column>
            <el-table-column
                prop="applyTime"
                label="申请提现时间"
                align="center">
            </el-table-column>
            <el-table-column
                prop="applyTime"
                label="处理时间"
                align="center">
            </el-table-column>
            <el-table-column
                prop="amount"
                label="提现金额"
                align="center">
            </el-table-column>
            <el-table-column
                prop="actual"
                label="实际转账"
                align="center">
            </el-table-column>
            <el-table-column
                prop="account"
                label="支付宝账户"
                align="center">
            </el-table-column>
            <el-table-column
                prop="name"
                label="名字"
                align="center">
            </el-table-column>
            <el-table-column label="操作" align="center" width="254">
                <template slot-scope="scope">
                    <el-button @click="onPassClick(scope.row)" size="small">执行</el-button>
                    <el-button @click="onNoPassClick(scope.row)" size="small">打回</el-button>
                    <el-button @click="onHistoryClick(scope.row)" size="small">历史明细</el-button>
                </template>
            </el-table-column>
        </el-table>
        <div class="footer-page">
        <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="page"
            :page-sizes="[10, 20, 50, 100]"
            :page-size="page_size"
            layout="total, sizes, prev, pager, next, jumper"
            :total="total_page">
        </el-pagination>
        </div>
    </div>
</template>

<script>
export default {
    name: 'withdraw-unhadle',
    data () {
        return {
            // dialogVisible: false,
            // del_station_id: '',
            page: 1,
            page_size: 10,
            total_page: 0,
            formInline: {
                city: '',
                nickname: ''
            },
            params: {
                city: '',
                nickname: '',
                page: 1,
                size: 10,
                status: 0
            },
            tableData: []
        }
    },
    created () {
        // this.tableData = []
    },
    mounted () {
        this.getList(this.params)
    },
    methods: {
        search () {
            this.params = {
                city: this.formInline.city,
                nickname: this.formInline.nickname,
                page: this.page,
                page_size: this.page_size,
                status: 0
            }
            this.getList(this.params)
        },
        reset () {
            this.formInline = {
                nickname: '',
                city: ''
            }
        },
        getList (params) {
            let data = {
                'params': params
            }
            let _this = this
            this.tableData = []
            this.$api.withdraw.gethandleList(data, res => {
                if (res.code === 200) {
                    let list = res.data.list || []
                    for (let i = 0; i < list.length; i++) {
                        _this.tableData.push(list[i])
                    }
                    _this.total_page = res.data.totalCount
                    _this.page = res.data.currPage
                    _this.page_size = res.data.pageSize
                }
            })
        },
        onPassClick (row) {
            let data = {
                id: row.userWithdrawId,
                status: 1
            }
            this.handleWithdrawCash(data)
        },
        onNoPassClick (row) {
            let data = {
                id: row.userWithdrawId,
                status: 2
            }
            this.handleWithdrawCash(data)
        },
        onHistoryClick (row) {
            this.$router.push({
                name: 'withdrawCash.history',
                params: {
                    id: row.id
                }
            })
        },
        handleSizeChange (val) {
            this.page = val
            this.params.page = 1
            this.params.size = val
            this.getList(this.params)
        },
        handleCurrentChange (val) {
            this.params.page = val
            this.getList(this.params)
        },
        handleWithdrawCash (param) {
            let data = {
                'params': param
            }
            let _this = this
            this.tableData = []
            this.$api.withdraw.handleData(data, res => {
                if (res.code === 200) {
                    _this.getList(this.params)
                }
            })
        }
    }
}
</script>

<style lang="less" scoped>
    .withdraw-unhadle {
        position: relative;
        width: 100%;
        height: 100%;
        .margin-bottom-12 {
            margin-bottom: 10px;
        }
        .el-row {
            margin-bottom: 20px;
            &:last-child {
                margin-bottom: 0;
            }
        }
        .el-col {
            border-radius: 4px;
        }
        .grid-content {
            position: relative;
            height: 40px;
        }
        .grid-padding {
            /* padding-left: 20px; */
            padding-right: 20px;
        }
        .grid-title {
            float: left;
            width: 72px;
            height: 40px;
            line-height: 40px;
            font-size: 14px;
            color: #333;
            text-align: center;
        }
        .grid-input {
            float: left;
            width: 130px;
            height: 40px;
            line-height: 40px;
            font-size: 14px;
            color: #333;
            text-align: center;
        }
        .row-bg {
            padding: 10px 0;
            background-color: #f9fafc;
        }
        .footer-page {
            width: 540px;
            margin: 0 auto;
            padding-top: 20px;
        }
    }
</style>
